<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<script type="text/javascript" src="Content/script/jquery-1.10.2.js"></script>
<script type="text/javascript" src="Content/script/jquery.validate.js"></script>
<script type="text/javascript">
	$(function(){
		$("#form").validate({
			rules:{
			title:{
			required:true},
			movieCode:{
			required:true},
			director:{
			required:true},
			date:{
			required:true}
			},
			messages:{
				title:{
			required:"请输入电影标题"},
			movieCode:{
			required:"请输入电影编号"},
			director:{
			required:"请输入电影导演"},
			date:{
			required:"请输入上映日期"}
				}
		});
		
		
	});
</script>
<style>
		label.error{color: red;}
</style>
  </head>
  
  <body> 
    <div>
    <p>编辑电影</p>
    <form action="SaveMovieServlet" method="post" id="form">
    <table border="1">
    <input type="hidden" value="${movie.id }" name ="id">
    <tr>
    	<td>电影名称：</td>
    	<td><input type="text" name="title" value="${movie.title }"/></td>
    </tr>
    
    <tr>
    	<td>电影编号：</td>
    	<td><input type="text" name="movieCode" value="${movie.movieCode }"/></td>
    </tr>
    <tr>
    	<td>电影海报：</td>
    	<td><input type="file" name="post"/></td>
    </tr>
    <tr>
    	<td>分类：</td>
    	<td>
    	<select name="cid">
    		<c:forEach items="${clist }" var="c">
    		<c:if test="${movie.category.id == c.id }">
    		<option value="${c.id }" selected="selected">${c.name }</option>
    		</c:if>
    		<c:if test="${movie.category.id != c.id }">
    		<option value="${c.id }">${c.name }</option>
    		</c:if>
    		</c:forEach>
    	</select>
    	</td>
    </tr>
    <tr>
    	<td>导演：</td>
    	<td><input type="text" name="director" value="${movie.director }"/></td>
    </tr>
    <tr>
    	<td>上映时间：</td>
    	<td><input type="text" name="date" value="${movie.dateReleased }"/></td>
    </tr>
    <tr>
    	<td></td>
    	<td><input type="submit" value="提交"/></td>
    </tr>
    </table>
    </form>
    </div>
  </body>
</html>
